const terserWebpackPlugin = require("terser-webpack-plugin");
const compressionWebpackPlugin = require("compression-webpack-plugin");

module.exports = {
  assetsDir: "static",
  productionSourceMap: false,
  transpileDependencies: ["element-ui", "vue-i18n"],
  devServer: {
    compress: true,
    proxy: {
      "/api": {
        target: "https://hzz.jiafen520.com/",
        changeOrigin: true,
        pathRewrite: {
          "^/api": "/",
        },
      },
    },
  },
  configureWebpack: {
    plugins: [
      new terserWebpackPlugin(),
      new compressionWebpackPlugin({
        test: /\.(js|css|html|svg|png|ico|woff|woff2|ttf|mp4)$/,
        threshold: 10240,
        minRatio: 0.8,
      }),
    ],
  },
  css: {
    loaderOptions: {
      sass: {
        sassOptions: {
          outputStyle: "expanded",
        },
      },
    },
  },
};
